<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="./decimal.js"></script>
    <script>
        // 1/1+1/2+1/3+...1/n-1+-10=-1/n
        // 1000/1+1000/2+1000/3+...1000/n-1=10000 
        // 请用JavaScript的递归方式，写出求n的代码



        // ln(n)-ln(n-1)=1/n


        // 1+1/2+1/3+1/4+...+1/2007+1/n-1 
        // f(n-1)+1/n = f(n)

        function f(n) {
            if (n == 1) {
                return 1000
            }
            return f(n - 1) + 1000 / n;
        }

        var i = 1;

        while (true) {
            var res = f(i)
            if (res >= 10000) {
                console.log(i);
                break;
            }
            i++;

        }

        // https://www.jianshu.com/p/37829c87faa9

        /*      let res = Decimal.add(0.1, 0.2)
             console.log(Number(res));

             x = Decimal(200.2)
             let res2 = x.minus(200)

             console.log(res2.toString());
             console.log(Number(res2)); */
    </script>

</body>

</html>